<?php
$flights = DealFlight::getSomeFlight(DealFlight::FLIGHT);
$deals = DealFlight::getFeaturedDeal();
?>
<?php get_header(); ?>

<div class="content">
  <div class="container">
    <div class=" box-sli">
      <div class="left-slider">
        <div class="qoute-box">
          <div class="title-qoute"> II Request a Quote </div>
          <div class="form-qoute">
            <form method="POST" >
              <div class="row01">
              <label>Name</label>
              <input type="text" id="name" name="name" value="<?php if(isset($_REQUEST['name'])){ echo $_REQUEST['name']; } ?>" />
              <span id="error-name" class="error" ></span>
              </div>
              
            <div class="row01">
              <label>Email</label>
              <input type="text" id="txt-email" name="txt-email" value="<?php if(isset($_REQUEST['txt-email'])){ echo $_REQUEST['txt-email']; } ?>" />
              <span id="error-email" class="error" ></span>
             </div>
              <div class="row01"> 
              <label> Phone number</label>
              <input type="text" id="txt-phone" name="txt-phone" value="<?php if(isset($_REQUEST['txt-phone'])){ echo $_REQUEST['txt-phone']; } ?>" />
              <span id="error-phone" class="error" ></span>
                </div>
              <div class="class_br"></div>
              <div class="row01">  
              <div>
                <input type="radio" name="typeFlights" id="typeFlights1" value="<?php echo DealFlight::ONEWAY; ?>" />
                <label class="label-flights">One Way</label>
                <input type="radio" checked="check" name="typeFlights" id="typeFlights2" value="<?php echo DealFlight::ROUNDTRIP; ?>" />
                <label class="label-flights" >Round Trip</label>
                <input type="radio" name="typeFlights" id="typeFlights3" value="<?php echo DealFlight::MULTICITY; ?>" />
                <label  class="label-flights2" >Multi City</label>
                <span id="error-type-flight" class="error" ></span> </div>
                </div>
                
              <div class="class_br"></div>
                 <div class="row01"> 
                   <div  id="content_leving">
                <label>Leaving from</label>
                <div class="ui-widget">
                  <input  placeholder="Enter City/state" type="text" id="leaving-from" 
						 name="leaving-from" class="txt-state-search"/>
                </div>
                <span id="error-leaving-form" class="error" ></span>
                <div class="class_br"></div>
                <label> Going to </label>
                <input type="text" placeholder="Enter City/state"  id="going-to" name="going-to" class="txt-state-search"/>
                <span id="error-going-to" class="error" ></span>
                <div class="class_br"></div>
                 <div class="row03"> 
                    <div class="heading01"> <span id="depart1" style="color: white !important;"> Departure date</span> <span style="color: white!important;" id="return1" > - Return date</span></div>
                    <br/>
                    <input type="text" style="width: 97px;" id="departure-date" name="departure-date" />
                    <img id="image_button" width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> 
                <span id="span-return-date" style="color: #ffffff !important;">-
                    <input type="text" style="width: 96px;" id="return-date" name="return-date" />
                    <img id="image_button2"   width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> 
                </span>
                 <span id="error-start-time" class="error" ></span>
                 <span id="error-end-time" class="error" ></span>
                  </div>
                  </div>
                 </div> 
                
                
              <div  id="content_leving2" style="display: none;">
                <div class="div-boder">
                  <label>Leaving from</label>
                  <input  placeholder="Enter City/state" type="text" id="leaving-from1" 
						name="leaving-from1" class="txt-state-search"/>
                  <span id="error-leaving-form1" class="error" ></span>
                  <div class="class_br"></div>
                  <label> Going to </label>
                  <input type="text" placeholder="Enter City/state"  id="going-to1" name="going-to1" class="txt-state-search"/>
                  <span id="error-going-to1" class="error" ></span>
                  <div class="class_br"></div>
                  <label><span id="depart1" style="color: white !important;"> Departure date</span><span style="color: white !important;" id="return1" > - Return date</span></label>
                  <br/>
                  <input type="text" style="width: 97px;" id="departure-date1" name="departure-date1" />
                  <img id="image_buttona1" width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> <span id="span-return-date" style="color: #ffffff !important;">-
                  <input type="text" style="width: 96px;" id="return-date1" name="return-date1" />
                  <img id="image_buttonb1"   width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> </span> <span id="error-start-time1" class="error" ></span> <span id="error-end-time1" class="error" ></span>
                  <hr/>
          
                    <label>Leaving from</label>
                    <input  placeholder="Enter City/state" type="text" id="leaving-from2"
						name="leaving-from2" class="txt-state-search"/>
                    <span id="error-leaving-form2" class="error" ></span> 
                  <div class="class_br"></div>
                
                    <label> Going to </label>
                    <input type="text" placeholder="Enter City/state"  id="going-to2" name="going-to2" class="txt-state-search"/>
                    <span id="error-going-to2" class="error" ></span> 
                  <div class="class_br"></div>
              
                    <label><span id="depart2"> Departure date</span><span style="color: white !important;" id="return1" > - Return date</span></label>
                    <br/>
                    <input type="text" style="width: 97px;" id="departure-date2" name="departure-date2" />
                    <img id="image_buttona2" width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> <span id="span-return-date" style="color: #ffffff !important;">-
                    <input type="text" style="width: 96px;" id="return-date2" name="return-date2" />
                    <img id="image_buttonb2"   width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> </span> <span id="error-start-time2" class="error" ></span> <span id="error-end-time2" class="error" ></span> </p>
                  <div class="id_tab3">
                    <hr/>
          
                      <label>Leaving from</label>
                      <input  placeholder="Enter City/state" type="text" id="leaving-from3" 
						    name="leaving-from3" class="txt-state-search"/>
                      <span id="error-leaving-form3" class="error" ></span> </p>
                    <div class="class_br"></div>
               
                      <label> Going to </label>
                      <input type="text" placeholder="Enter City/state"  id="going-to3" name="going-to3" />
                      <span id="error-going-to3" class="error" ></span> </p>
                    <div class="class_br"></div>
                  
                      <label><span id="depart3" style="color: white !important;"> Departure date</span><span style="color: white !important;" id="return3" > - Return date</span></label>
                      <br/>
                      <input type="text" style="width: 97px;" id="departure-date3" name="departure-date3" />
                      <img id="image_buttona2" width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> <span id="span-return-date" style="color: #ffffff !important;">-
                      <input type="text" style="width: 96px;" id="return-date3" name="return-date3" />
                      <img id="image_buttonb3"   width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> </span> <span id="error-start-time3" class="error" ></span> <span id="error-end-time3" class="error" ></span> </p>
                  </div>
                  <div class="id_tab4">
                    <hr/>
          
                      <label>Leaving from</label>
                      <input  placeholder="Enter City/state" type="text" id="leaving-from4"
						    name="leaving-from4" class="txt-state-search"/>
                      <span id="error-leaving-form4" class="error" ></span> 
                    <div class="class_br"></div>
     
                      <label> Going to </label>
                      <input type="text" placeholder="Enter City/state"  id="going-to4" name="going-to4" class="txt-state-search"/>
                      <span id="error-going-to4" class="error" ></span> </p>
                    <div class="class_br"></div>
     
                      <label><span id="depart4" style="color: white !important;"> Departure date</span><span style="color: white !important;" id="return4" > - Return date</span></label>
                      <br/>
                      <input type="text" style="width: 97px;" id="departure-date4" name="departure-date4" />
                      <img id="image_buttona4" width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> <span id="span-return-date" style="color: #ffffff !important;">-
                      <input type="text" style="width: 96px;" id="return-date4" name="return-date4" />
                      <img id="image_buttonb4"   width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> </span> <span id="error-start-time4" class="error" ></span> <span id="error-end-time4" class="error" ></span> </p>
                  </div>
                  <input type="button" value="+ Add more flights"  class="bttngrey" id="addMoreBtnMulti_int" tabindex="20">
                  <input type="hidden" value="2" name="morest" id="morest"  />
                </div>
              </div>
              <div> </div>
              <div class="class_br"></div>
                 <div class="personWrapper">
                         <div class="row04">  
                            <label class="div_type_human">Adult(12+) </label>
                            <select  id="Adult" name="Adult" class="select-find-flights" >
                              <?php
                                                for ($i = 1; $i <= 9; $i++) {
                                                    echo '<option value="' . $i . '" >' . $i . '</option>';
                                                }
                                                ?>
                            </select>
                           </div>
                         <div class="row04">  
                            <label class="div_type_human">Children(2-12)</label>
                            <select  id="numCHD" name="numCHD" class="select-find-flights" >
                              <?php
                                                for ($i = 0; $i < 9; $i++) {
                                                    echo '<option value="' . $i . '" >' . $i . '</option>';
                                                }
                                                ?>
                            </select>
            
                    </div>  
                         <div class="row04">  
                            <label class="div_type_human" > Infant(0-2)</label>
                            <select id="infant"  class="select-find-flights">
                              <option>0</option>
                              <option>1</option>
                            </select>
            </div>
                 </div> 


                  <div class="warappr2">
                       <div class="row04">  
                <label  class="div_type_human"> Class </label>
                <select name="" id="class" class="select-find-flights">
                <option value="<?php echo DealFlight::ECONOMY; ?>">Economy</option>
                <option value="<?php echo DealFlight::BUSINESS; ?>">Business</option>
                <option value="<?PHP echo DealFlight::FIRST_CLASS ?>">First Class</option>
                <option value="<?php echo DealFlight::PREMIUM_ECONOMY ?>">Premium Economy</option>
                </select>
                </div>
                       <div class="row04">  
                <label  class="div_type_human"> Country </label>
                <select name="city" id="city" class="select-find-flights country-select" >
                  <?php $countries = Country::listCountry();?>
                  <?php foreach($countries as $key=>$value){
					echo '<option value="'.$key.'">'.$value.'</option>';
					}?>
                </select>
                </div>
                  </div>
              

       
        <div class="submitWrapper">
             <input type="button" class="button"  name="tb-search-flights" id="tb-search-flights"  value="Submit" />
        </div>
                
     
              <?php
                            //  echo do_shortcode('[contact-form-7 id="44"  title="Request a Quote"]');
                            ?>
            </form>
          </div>
        </div>
      </div>
      <!--col-md-4-->
      <div class="right-slider">
        <div id="sitewrapper">
          <section class="sliderwrapper">
            <div id="slider" data-source="<?php echo get_site_url(); ?>" data-speed="500" data-easing="swing"> 
              <!-- Extern-Content loading works only on (simulated) server --> 
              <!-- <div id="slider" data-source="slider-content.html" data-speed="500" data-easing="swing"> -->
              <ul>
                <?php
                                $listSlider = Post::AllPostSliderTop();
                                foreach ($listSlider as $row) {
                                    $idSlider = $row->ID;
                                    $titleSlider = $row->post_title;
                                    $imgSlider = Post::get_thumbbyIDPpost($idSlider);
                                    $content = $row->post_content;
                                    $content = strip_tags($content);
                                    $content = substr($content, 0, 100);
                                    ?>
                <li class="hslide" data-id="hashslider<?php echo $idSlider; ?>">
                  <div> <img src="<?php echo $imgSlider; ?>">
                    <div class="text-sli">
                      <h1><?php echo $titleSlider; ?></h1>
                      <h4><?php echo $content; ?></h4>
                    </div>
                  </div>
                </li>
                <?php
                                }
                                ?>
              </ul>
            </div>
            <div class="pagination">
              <div id="numbers"></div>
            </div>
            <a class="button" id="back"></a> <a class="button" id="next"></a> </section>
          <!--end sitewrapper--> 
        </div>
        <?php ?>
      </div>
      <!--col-md-8--> 
    </div>
    <!--row-->
    
    <div class="travel">
      <h3>HOT DEAL</h3>
      <?php
            foreach ($deals as $deal) {
                $start_time = strtotime($deal->start_time);
                $end_time = strtotime($deal->end_time);
                $days_between = ceil(abs($end_time - $start_time) / 86400);

                $day = explode(" ", $deal->end_time);
                $houseEnd = $day[1];
                $houseEnd = explode(":", $houseEnd);

                if ($houseEnd[0] > 12) {
                    $night = $days_between;
                } else {
                    $night = (int) $days_between - 1;
                }
                
                ?>
      <li>
        <?php 
		    $aImages = unserialize($deal->image);
		    foreach($aImages as $img){
		    ?>
        <img src="<?php echo TIMTHUMB_URL ?>?src=<?php echo DEAL_URL . $img ?>&w=227&h=152"/>
        <?php 
		    break;
		    }?>
        <div class="travel-titl"> <a  style="color: white" href="detail-deal/?i=<?php echo $deal->deal_flight_id; ?>"><?php echo $deal->name_deal ?></a>
          <p> <?php echo $night ?>N / <?php echo $days_between; ?>D</p>
        </div>
      </li>
      <?php }
            ?>
    </div>
    <!--travel-->
    
    <div class="line-bottom">
      <div class="deals">
        <p>Travel deals</p>
        Direct into your inbox </div>
      <div class="phone">
        <p>Enquire Now</p>
        214-221-3300 </div>
    </div>
  </div>
  <!-- content--> 
</div>
<!-- container-->

<?php get_footer(); ?>
<?php
/*
 * Add script cua datetime picker
 */
?>
<script type="text/javascript" lang="javascript">


    jQuery('#image_button').click(function() {
        jQuery('#departure-date').datetimepicker('show'); //support hide,show and destroy command
    });

    jQuery('#image_button2').click(function() {
        jQuery('#return-date').datetimepicker('show'); //support hide,show and destroy command
    });


    jQuery(function() {
        jQuery('#departure-date').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    maxDate: jQuery('#return-date').val() ? jQuery('#return-date').val() : false
                })
            },
            timepicker: false
        });
        jQuery('#return-date').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    minDate: jQuery('#departure-date').val() ? jQuery('#departure-date').val() : false
                })
            },
            timepicker: false
        });
    });


    jQuery('#image_buttona1').click(function() {
        jQuery('#departure-date1').datetimepicker('show'); //support hide,show and destroy command
    });

    jQuery('#image_buttonb1').click(function() {
        jQuery('#return-date1').datetimepicker('show'); //support hide,show and destroy command
    });


    jQuery(function() {
        jQuery('#departure-date1').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    maxDate: jQuery('#return-date1').val() ? jQuery('#return-date1').val() : false
                })
            },
            timepicker: false
        });
        jQuery('#return-date1').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    minDate: jQuery('#departure-date1').val() ? jQuery('#departure-date1').val() : false
                })
            },
            timepicker: false
        });
    });


    jQuery('#image_buttona2').click(function() {
        jQuery('#departure-date2').datetimepicker('show'); //support hide,show and destroy command
    });

    jQuery('#image_buttonb2').click(function() {
        jQuery('#return-date2').datetimepicker('show'); //support hide,show and destroy command
    });


    jQuery(function() {
        jQuery('#departure-date2').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    maxDate: jQuery('#return-date2').val() ? jQuery('#return-date2').val() : false
                })
            },
            timepicker: false
        });
        jQuery('#return-date2').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    minDate: jQuery('#departure-date2').val() ? jQuery('#departure-date2').val() : false
                })
            },
            timepicker: false
        });
    });
    
    
    
    
     jQuery('#image_buttona3').click(function() {
        jQuery('#departure-date3').datetimepicker('show'); //support hide,show and destroy command
    });

    jQuery('#image_buttonb3').click(function() {
        jQuery('#return-date3').datetimepicker('show'); //support hide,show and destroy command
    });


    jQuery(function() {
        jQuery('#departure-date3').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    maxDate: jQuery('#return-date3').val() ? jQuery('#return-date3').val() : false
                })
            },
            timepicker: false
        });
        jQuery('#return-date3').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    minDate: jQuery('#departure-date3').val() ? jQuery('#departure-date3').val() : false
                })
            },
            timepicker: false
        });
    });
    
     
     jQuery('#image_buttona4').click(function() {
        jQuery('#departure-date4').datetimepicker('show'); //support hide,show and destroy command
    });

    jQuery('#image_buttonb4').click(function() {
        jQuery('#return-date4').datetimepicker('show'); //support hide,show and destroy command
    });


    jQuery(function() {
        jQuery('#departure-date4').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    maxDate: jQuery('#return-date4').val() ? jQuery('#return-date4').val() : false
                })
            },
            timepicker: false
        });
        jQuery('#return-date4').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    minDate: jQuery('#departure-date4').val() ? jQuery('#departure-date4').val() : false
                })
            },
            timepicker: false
        });
    });

</script> 